﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Datos
{
    public class ConfiguracionDAO
    {

        private SqlConnection conexion = null;
        private ConnectionStringSettings cadena = null;
        private DbConnection conexionDB = null;
        private DbCommand comando = null;
        private DbTransaction transaccion = null;
        private string cadenaConexion;
        private static DbProviderFactory factory = null;


        public void ConectarToDB()
        {
            try
            {
                cadena = ConfigurationManager.ConnectionStrings["BDInmobiliaria"];

                using (conexion = new SqlConnection())
                {
                    conexion.ConnectionString = cadena.ConnectionString;
                    conexion.Open();

                    if (conexion.State == ConnectionState.Open)
                    {
                        var CadenaBD = "Base de datos: " + conexion.Database +
                       "Origen de datos: {0}" + conexion.DataSource +
                        "Servidor: {0}" + conexion.WorkstationId +
                       "Version: {0}" + conexion.ServerVersion +
                         "\nCadena Conexion: {0}" + conexion.ConnectionString;
                        MessageBox.Show(CadenaBD, "Inmobiliaria", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "Inmobiliaria", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                if (conexion.State == ConnectionState.Closed)
                {
                    MessageBox.Show("Conexion Cerrada", "Inmobiliaria", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }

    }
}
